package com.xbell.app.sys.controller;

import java.util.Date;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.nacos.common.utils.DateFormatUtils;
import com.xbell.app.sys.common.ResponseMessage;
import com.xbell.app.sys.entity.XbUser;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import springfox.documentation.annotations.ApiIgnore;

@RestController
@RequestMapping(value="user")
@Api(tags={"用户管理","测试控制"})
public class UserController {
	
	@ApiOperation("增加用户")
	@ApiResponses({@ApiResponse(description="成功",responseCode="200",content=@Content(examples=@ExampleObject(value="{code:200,data:'',msg:''}")))})
	@GetMapping("addUser")
	public ResponseMessage<Object> addUser(@ApiParam(name="姓名",value="姓名_val",required = true,defaultValue = "张三丰") String name,@ApiParam("密码") String pwd,String phone){
//		for(int i=0;i<100;i++) {
//			new Thread() {
//				public void run() {
//					HomeController.this.test();
//				}
//			}.start();
//			
//		}
		return ResponseMessage.ok(name);
	}
	
	@ApiOperation("删除用户")
	@ApiResponses({@ApiResponse(description="成功",responseCode="200",content=@Content(examples=@ExampleObject(value="{code:200,data:'',msg:''}")))})
	@PostMapping("delUser")
	public ResponseMessage<Object> delUser(String user,String ids) {
		System.out.println(DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
		return null;
	}
	
	@ApiOperation("用户详情")
	@ApiResponses({@ApiResponse(description="成功",responseCode="200",content=@Content(examples=@ExampleObject(value="{code:200,data:'',msg:''}")))})
	@PostMapping("userInfo")
	public ResponseMessage<XbUser> userInfo(XbUser user) {
		System.out.println(DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
		return null;
	}
	
	//@Operation()
	//@ApiOperation("用户详情2")
	//@ApiResponses({@ApiResponse(description="成功",responseCode="200",content=@Content(examples=@ExampleObject(value="{code:200,data:'',msg:''}")))})
	@PostMapping("userInfo2")
	public ResponseMessage<XbUser> userInfo2(XbUser user) {
		System.out.println(DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
		return null;
	}
	
	@PostMapping("userInf3")
	public ResponseMessage<XbUser> userInfo3(XbUser user) {
		System.out.println(DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
		return null;
	}
	
	
}
